package org.usfirst.frc;

public class Manipulator implements Scheduleable 
{
private final int openPressed = 0,  openUnpressed = 1, closePressed = 2, closeUnpressed = 3;
private int clawState = openUnpressed;
    
public void open()
{
IOThread.setSolenoidOut(0, false);
IOThread.setSolenoidOut(1, true);
}

public void close()
{
IOThread.setSolenoidOut(0, false);
IOThread.setSolenoidOut(1, true);
}

public void run() 
	{
	double val =IOThread.getJoyAxes(2, 4);
		
	switch(clawState)
	{
	case openPressed:
		if(val == 0)
		clawState = openUnpressed;
		break;
	case openUnpressed:
		if(val != 0)
			{
			close();
			clawState = closePressed;
			}
		break;
	case closePressed:
		if(val == 0)
		clawState = closeUnpressed;
		break;
	case closeUnpressed:
		if(val != 0)
			{
			open();
			clawState = openPressed;
			}
		break;
	}
	}
}
